<template>
  <div id="app">
    <!-- 显示的占位符 -->
    <router-view/>
    <!-- 通过全局组件实现路由跳转 -->
    <!-- 
    <router-link to="/Shopping">购物车</router-link>
    <router-link to="/HelloWorld">你好</router-link>
    <router-link to="/About">关于</router-link>
    <router-link to="/Home">主页</router-link> -->

    <!-- 通过代码方式实现路由跳转 -->
    <button @click="aboutClick">关于</button>
    <button @click="helloClick">你好</button>
    <button @click="homeClick">首页</button>
    <button @click="shoppClick">购物车</button>
  </div>
</template>

<script>
export default {
  name: 'App',
  methods:{
    aboutClick(){
      // 路由跳转,经过router
      // this.$router.push('/About');
      // this.$router.replace('/About');
      location.hash = '/About'
    },
    helloClick(){
      // this.$router.push('/HelloWorld');
      // this.$router.replace('/HelloWorld');
      location.hash = '/HelloWorld'
    },
    homeClick(){
      // this.$router.push('/Home');
      // this.$router.replace('/Home');
      location.hash = '/Home'
    },
    shoppClick(){
      // this.$router.push('/Shopping');
      // this.$router.replace('/Shopping');
      location.hash = '/Shopping'
    }

  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
